package sgd.tp2.api.cdr;

import java.io.Serializable;
import java.util.Random;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

import com.google.gson.annotations.SerializedName;

@XmlRootElement(name = "cdr")
public final class CDR implements Serializable {

	private static final long serialVersionUID = 9207605670598423427L;
	private static final String[] NAMES = {"Joao", "Ana", "Pedro", "Silvia", "Miguel", "Teresa", "Luis" };

	@SerializedName("caller_id")
	private String callerId;
	@SerializedName("duration")
	private int duration;
	@SerializedName("billsec")
	private int billSec;
	@SerializedName("progresssec")
	private int progressSec;
	@SerializedName("progress_mediasec")
	private int progressMediaSec;
	@SerializedName("flow_billsec")
	private int flowBillSec;
	@SerializedName("mduration")
	private long mDuration;
	@SerializedName("billmsec")
	private long billMSec;
	@SerializedName("progressmsec")
	private long progressMSec;
	@SerializedName("progress_mediamsec")
	private long progressMediaMSec;
	@SerializedName("flow_billmsec")
	private long flowBillMSec;
	@SerializedName("uduration")
	private long uDuration;

	public static CDR getWithRandomData() {

		Random rand = new Random(System.currentTimeMillis());

		CDR record = new CDR();
		record.setCallerId(NAMES[rand.nextInt(7)]);
		record.setDuration(rand.nextInt() & 0x7fffffff);
		record.setBillSec(rand.nextInt() & 0x7fffffff);
		record.setProgressSec(rand.nextInt() & 0x7fffffff);
		record.setProgressMediaSec(rand.nextInt() & 0x7fffffff);
		record.setFlowBillSec(rand.nextInt() & 0x7fffffff);
		record.setmDuration(rand.nextLong() & 0x7fffffff);
		record.setBillMSec(rand.nextLong() & 0x7fffffff);
		record.setProgressMSec(rand.nextLong() & 0x7fffffff);
		record.setProgressMediaMSec(System.nanoTime());
		record.setFlowBillMSec(rand.nextLong() & 0x7fffffff);
		record.setuDuration(rand.nextLong() & 0x7fffffff);

		return record;
	}

	public void setCallerId(String callerId) {
		this.callerId = callerId;
	}

	@XmlElement(name = "caller_id", required = true)
	public String getCallerId() {
		return callerId;
	}

	public void setDuration(int duration) {
		this.duration = duration;
	}

	@XmlElement(name = "duration", required = true)
	public int getDuration() {
		return duration;
	}

	public void setBillSec(int billSec) {
		this.billSec = billSec;
	}

	@XmlElement(name = "billsec", required = true)
	public int getBillSec() {
		return billSec;
	}

	public void setProgressSec(int progressSec) {
		this.progressSec = progressSec;
	}

	@XmlElement(name = "progresssec", required = true)
	public int getProgressSec() {
		return progressSec;
	}

	public void setProgressMediaSec(int progressMediaSec) {
		this.progressMediaSec = progressMediaSec;
	}

	@XmlElement(name = "progress_mediasec", required = true)
	public int getProgressMediaSec() {
		return progressMediaSec;
	}

	public void setFlowBillSec(int flowBillSec) {
		this.flowBillSec = flowBillSec;
	}

	@XmlElement(name = "flow_billsec", required = true)
	public int getFlowBillSec() {
		return flowBillSec;
	}

	public void setmDuration(long mDuration) {
		this.mDuration = mDuration;
	}

	@XmlElement(name = "mduration", required = true)
	public long getmDuration() {
		return mDuration;
	}

	public void setBillMSec(long billMSec) {
		this.billMSec = billMSec;
	}

	@XmlElement(name = "billmsec", required = true)
	public long getBillMSec() {
		return billMSec;
	}

	public void setProgressMSec(long progressMSec) {
		this.progressMSec = progressMSec;
	}

	@XmlElement(name = "progressmsec", required = true)
	public long getProgressMSec() {
		return progressMSec;
	}

	public void setProgressMediaMSec(long progressMediaMSec) {
		this.progressMediaMSec = progressMediaMSec;
	}

	@XmlElement(name = "progress_mediamsec", required = true)
	public long getProgressMediaMSec() {
		return progressMediaMSec;
	}

	public void setFlowBillMSec(long flowBillMSec) {
		this.flowBillMSec = flowBillMSec;
	}

	@XmlElement(name = "flow_billmsec", required = true)
	public long getFlowBillMSec() {
		return flowBillMSec;
	}

	public void setuDuration(long uDuration) {
		this.uDuration = uDuration;
	}

	@XmlElement(name = "uduration", required = true)
	public long getuDuration() {
		return uDuration;
	}
}
